//
//  NewsViewController.m
//  Mtime
//
//  Created by Mac on 15/8/8.
//  Copyright (c) 2015年 wxk. All rights reserved.
//

#import "NewsViewController.h"

@interface NewsViewController ()

@end

@implementation NewsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH -64)];
    
    webView.scalesPageToFit = YES;
    
    //1.获得标签文件
    NSString *path = [[NSBundle mainBundle] pathForResource:@"news" ofType:@"html"];
    
    //2.将标签文件转换成字符串 ——> 方便我门去填充内容
    NSString *dataString = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    
    //3.填充数据
    NSDictionary *newsDic = [CoreDataSource initWithDataSource:@"newsDetail2"];
    /*
     "title": "《解救吾先生》曝态度版预告",
     "title2": "刘德华刘烨众硬汉登场 丁晟“不要颜值要演技”",
     "content": "<br><br><div>　　<b>时光网讯</b> 近日，由丁晟执导，刘德华、刘烨、吴若甫、王千源等主演的警匪电影《解救吾先生》曝光了导演
     "time": "2015-7-14 13:40:54",
     "source": "Mtime时光网",
     "author": "",
     "editor": "Gilda",
     "commentCount": 5,
     "url": "http://news.mtime.com/2015/07/14/1544620.html",
     */
    //3.1获得填充数据
    NSString *title = [newsDic objectForKey:@"title"];
    
    self.title = title;
    
    NSString *title2 = [newsDic objectForKey:@"title2"];
    NSString *content = [newsDic objectForKey:@"content"];
    NSString *time = [newsDic objectForKey:@"time"];
    NSString *source = [newsDic objectForKey:@"source"];
    
    //3.2 将填充数据填入标签文件中
    NSString *htnlString = [NSString stringWithFormat:dataString,title2,content,time,source];
    
    //4.加载数据
    [webView loadHTMLString:htnlString baseURL:[NSURL URLWithString:[[NSBundle mainBundle] bundlePath]]];
    /*
     webView loadHTMLString:<#(NSString *)#> baseURL:<#(NSURL *)#>
     
     webView loadData:<#(NSData *)#> MIMEType:<#(NSString *)#> textEncodingName:<#(NSString *)#> baseURL:<#(NSURL *)#>

     */
    [self.view addSubview:webView];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
